package ACWing.Greed;
//907. 区间覆盖

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

/**
 * @author :chenjie
 * @date :Created 2023/1/14 17:49
 */
public class IntervalCoverage {
    static class Pall{
        int x;
        int y;

        public Pall(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return "Pall{" +
                    "x=" + x +
                    ", y=" + y +
                    '}';
        }
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int s=sc.nextInt();
        int t=sc.nextInt();
        int n=sc.nextInt();
        List<Pall> list=new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int a=sc.nextInt();
            int b=sc.nextInt();
            list.add(new Pall(a,b));
        }
        list.sort(new Comparator<Pall>() {
            @Override
            public int compare(Pall o1, Pall o2) {
                return o1.x-o2.x;

            }
        });
        int num=1,max=list.get(0).x;//0不是最小的情况注意
        for (int i = 0; i < list.size(); i++) {
            if(list.get(i).x>s){
                if(max==list.get(0).x){//解决访问不到的情况
                    System.out.println(-1);
                    return;
                }
                s=max;
                num++;
            }
            if(list.get(i).x<=s){
                if(max<list.get(i).y){
                    max=list.get(i).y;
                }
            }
            if(max>=t){
                System.out.println(num);
                return;
            }
        }
        System.out.println(-1);
    }
}
